1 GuideTry... Catch... Finally is probably a familiar statement, and it seems easy to understand logically. However, the lessons I personally learned tell me that this is not as simple and obedient as I imagined. Believe it? Let's take a look at the
1. What is a try block?A try block is a block of code that can produce an exception, and a try block may follow a catch block or a finally block, or both.The semantics of the try block:try{ //statements that could cause an exception}2. What is a
Try-catch in-depth understandingLet's look at an example (example 1) to explain the process of try, catch, finally in Java
1234567891011121314151617181920212223
publicclassTryCatchFinally
There is a return statement in the try and finally block where no exception is thrown in the 1:try block[Java]View PlainCopy
Public static int noexception () {
int i=10;
try{
System.out.println ("I in Try block is" +i);
return-I.;
}
Example of a try catch catch exception in PHP, Trycatch
This example describes a try catch catch exception in PHP. Share to everyone for your reference. The specific methods are analyzed as follows:
In PHP, try catch can help us catch the exception
windhaunting, original addressUsed to be try{} catch (...) {} to catch some unexpected exceptions in C + +, today read Winhack's post only to know, this method in VC is actually unreliable. For example, the following code: Try { BYTE* pch;
This example describes a try catch catch exception in PHP. Share to everyone for your reference. The specific methods are analyzed as follows:
Try catch in PHP can help us catch the exception of the program code, so that we can deal with some
Mxs&vincene─╄ovё&0000021─╄ovёmxs&vinceneMxs&vincene─╄ovё: Today is very cruel, tomorrow is more brutal, the day after tomorrow is very good, but most people die in the evening, only those real heroes can see the sun after the day.Mxs&vincene─╄ovё:we
The Try-catch statement can also include the third part, which is the finally clause. It represents what should be done regardless of whether an exception occurs. The general syntactic form of the try-catch-finally statement is:Try { // may
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.